import pinia from '@/store';
import useUserStore from '@/store/modules/user';
let userStore = useUserStore(pinia);

export const isHasButton = (app: any) => {
  //全局自定义指令：实现按钮权限
  app.directive('has', {
    //使用该指令组件挂载时调用
    mounted(el: any, options: any) {
      if (!userStore.buttons.includes(options.value)) {
        //用户没有该按钮权限，删除dom
        el.parentNode.removeChild(el);
      }
    },
  });
};
